let net = require('net')
let socket = new net.Socket()
let options = {
'host': process.argv[2] ,
'port': process.argv[3]
}
socket.on('connect', function () {
console.log('connect');
let buf = buffer.from(new String('this is a test'));
socket.write(buf);
})
socket.on('data',console.log);
socket.on('error', console.error);
console.log("try",options.host,"port",options.port )
socket.connect(options)
openSocket() {
this.merge = this.socketMerge;
this.socket = io.connect(this.serverURI), {
'reconnection': true,
'reconnectionDelay': 1500,
'reconnectionDelayMax': 3000,
'reconnectionAttempts': 3
};
this.socket.on("update", data => {
this.update(data);
this.mergeLocal;
if (this.onSocketDataUpdate)
this.onSocketDataUpdate(data);
});
}
;
closeSocket() {
this.socket.closeSocket();
this.merge = this.defalutmerge;
}
socketMerge() {
var diff = this.mergeLocal();
this.socket.emit("update", diff);
}